package UILayer;
import javax.swing.*;
import javax.swing.border.*;
import java.awt.*;  

class Print extends JFrame 
{  
    private int w;
    private int h;
    private String string;

    public Print(int w, int h,  String string, String color)  
    {   
        this.w = w;
        this.h = h;
        this.string = string;
        this.setSize(w,h);  
        switch(color){
            case "red":
            this.setBackground(Color.RED);
            break;
            case "blue":
            this.setBackground(Color.BLUE);
            break;
            case "yellow":
            this.setBackground(Color.YELLOW);
            break;
            case "green":
            this.setBackground(Color.GREEN);
            break;
             case "white":
            this.setBackground(Color.WHITE);
            break;
        }
        
        this.setResizable(false);
        this.setVisible(true);  

    }  

    public void paint(Graphics g)  
    {  
        Dimension d = this.getSize();
        drawCenteredString(string, d.width, d.height, g);
         Graphics2D g2 = (Graphics2D) g;
        g2.drawRect(10,33,w-21,h-43);
    }  

    public void drawCenteredString(String s, int w, int h, Graphics g) {
        FontMetrics fm = g.getFontMetrics();
        int x = (w - fm.stringWidth(s)) / 2;
        int y = (fm.getAscent() + (h - (fm.getAscent() + fm.getDescent())) / 2);
        g.drawString(s, x, y);
    }

}  